package com.dengqi.mymodule.activity.fragment.tabpager;

import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

public class QViewPagerAdapter extends FragmentPagerAdapter {
    private List<QTabPager.TabBean> mTabList ;

    public QViewPagerAdapter(FragmentManager fm) {
        super(fm);
        this.mTabList = new ArrayList<>();
    }

    public void setTabList(List<QTabPager.TabBean> tabList){
        this.mTabList = tabList;
    }

    @Override
    public int getCount() {
        return mTabList.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if(mTabList.size()>0){
            return mTabList.get(position).getTitle();
        }else{
            return super.getPageTitle(position);
        }
    }

    @Override
    public Fragment getItem(int position) {
        return mTabList.get(position).getFragment();
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        return super.instantiateItem(container, position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        super.destroyItem(container, position, object);
    }


}
